package org.symkom.main;

import java.awt.CardLayout;

import javax.swing.JFrame;
import javax.swing.JPanel;

import org.symkom.card.Card;
import org.symkom.card.FunctionPane;
import org.symkom.card.GraphPane;
import org.symkom.card.ParametersPane;
import org.symkom.states.Panes;
import org.symkom.states.States;

public class MainWindow extends JFrame{
	int width;
	int height;
	
	int state;
	JPanel pane;
	JPanel functionPane;
	JPanel parametersPane;
	
	public MainWindow() {
		
		super("Temat Projektu");
	    setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
		
	    width = 1024;
	    height = 768;
	    
	    setSize(width, height);
	    setLocation(100, 15);
	    setVisible(true);
	    
	    
	    init();
	}
	
	public void init() {
		pane = new JPanel(new CardLayout());
		
		add(pane);
		setState(States.FUNCTION, null);
	}
	public void setState(int state, Card prev) {
		this.state = state;
		switchPane(prev);
	}
	private void switchPane(Card prev) {
		
		CardLayout cl = (CardLayout) pane.getLayout();
		switch(state) {
		case States.FUNCTION:
			pane.add(new FunctionPane(this, prev), Panes.FUNCTION);
			cl.show(pane, Panes.FUNCTION);
			break;
		case States.PARAMETER:
			pane.add(new ParametersPane(this, prev), Panes.PARAMETER);
			cl.show(pane, Panes.PARAMETER);
			break;
		case States.GRAPH:
			pane.add(new GraphPane(this, prev), Panes.GRAPH);
			cl.show(pane, Panes.GRAPH);
			break;	
		}
	}
	public static void main(String[] args) {
		new MainWindow();
	}
}
